﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;

public class OpenDaiji : MonoBehaviour
{
    public Sprite[] sprites = new Sprite[3];
    Timer timer;
    int index = 0;
    // Use this for initialization
    void Start()
    {
        
    }

    public void OnEnable()
    {
        timer = TimerMngr.Instance.Create(ChangeImage, 10000, true);
        timer.Start(5);
    }

    public void OnDisable()
    {
        TimerMngr.Instance.Destroy(timer);
    }

    void ChangeImage()
    {
        GameManager.T_daijiTweener = transform.GetComponent<Image>().DOColor(new Color(1, 1, 1, 0), GameManager.f_daijiani);
        GameManager.T_daijiTweener.OnComplete<Tweener>(() => {
            index = index + 1;
            index = index > 2 ? 0 : index;
            transform.GetComponent<Image>().sprite = sprites[index];
            GameManager.T_daijiTweener = transform.GetComponent<Image>().DOColor(new Color(1, 1, 1, 1), GameManager.f_daijiani);
        });
        
    }
}
